package com.rongshu.utils;

import android.animation.ValueAnimator;
import android.view.View;

public class AnimtionHelper {

    /**
     * 高度渐变的动画
     */
    public static void animHeightToView(final View v, final int start, final int end, long duration) {
        ValueAnimator va = ValueAnimator.ofInt(start, end);
        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int h = (int) animation.getAnimatedValue();
                v.getLayoutParams().height = h;
                v.requestLayout();
            }
        });
        va.setDuration(duration);
        va.start();
    }

    public static void animHeightToView( final View v, final long duration) {
        animHeightToView(v, 0, v.getLayoutParams().height, duration);
    }
}
